from selenium import webdriver
import page

class GetDriver:
    driver = None

    #获取driver
    @classmethod
    def get_driver(cls):
        if cls.driver is None:
            #获取driver
            cls.driver = webdriver.Firefox()
            #最大化浏览器
            cls.driver.maximize_window()
            #打开url
            cls.driver.get(page.URL) #通过包名. 获取包__init__里的变量

        #返回driver
        return cls.driver

    #关闭driver
    @classmethod
    def quit_driver(cls):
        if cls.driver:
            cls.driver.quit()
            #必须置空driver操作
            cls.driver = None